package com.infore.airsupervise.adapter;

import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.infore.airsupervise.R;
import com.infore.airsupervise.bean.EventE;

/**
 * 事件处理item适配器
 * Created by wutao on 2017/8/23.
 */

public class HandleEventAdapter extends BaseQuickAdapter<EventE, BaseViewHolder> {
    private String flag = null ;

    public HandleEventAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, EventE item) {
        helper.setText(R.id.event_item_title , item.getEventName());
        helper.setText(R.id.event_item_time , item.getEventTime());
        helper.setText(R.id.event_item_desc , item.getDescriptions());
         flag = item.getFlag();
        TextView tv_flag = helper.getView(R.id.event_item_handler);
        if(TextUtils.equals(flag,"0")){
            tv_flag.setText("未处理");
            tv_flag.setTextColor(ContextCompat.getColor(helper.getConvertView().getContext() , R.color.air_level_5));
        }else if(TextUtils.equals(flag,"1")){
            tv_flag.setText("处理中");
            tv_flag.setTextColor(ContextCompat.getColor(helper.getConvertView().getContext() , R.color.air_level_1));
        }else {
            tv_flag.setText("已完成");
            tv_flag.setTextColor(ContextCompat.getColor(helper.getConvertView().getContext() , R.color.air_level_0));
        }
    }
}
